package coba.mailing.properties;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class MainProperties {

	private static MainProperties INSTANCE = null;
	private Properties properties = null;

	private MainProperties() throws IOException {
		properties = new Properties();

		File f = new File("/opt/mailing/main.properties");

		if (f.exists() && !f.isDirectory()) {
			InputStream is = new FileInputStream(f);
			properties.load(is);
			is.close();
		}
		else {
			properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("main.properties"));
		}
	}

	public static synchronized MainProperties getInstance() throws IOException {
		if (INSTANCE == null)
			INSTANCE = new MainProperties();

		return INSTANCE;
	}

	public String getProperty(String name) {
		return properties.getProperty(name);
	}

}
